package com.yituo.mjworld.mvc.entity.web;

import com.yituo.mjworld.core.annotation.Rules;
import com.yituo.mjworld.core.web.core.BaseForm;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Date;

@Entity
@Table(name = "product", schema = "web_mojianworld_server", catalog = "")
public class Product extends BaseForm {
  @Rules(id = true, fieldName = "ID", min = "0")
  public int id;
  @Rules(fieldName = "排序的序号", required = false)
  public int orderNum;
  @Rules(fieldName = "商品名称")
  public String name;
  @Rules(fieldName = "商品说明", required = false)
  public String mark;
  @Rules(fieldName = "销售价格")
  public BigDecimal salePrice;
  @Rules(fieldName = "专柜价格")
  public BigDecimal shoppePrice;
  @Rules(fieldName = "商品数量", min = "0")
  public int num;
  @Rules(fieldName = "已售出数量", min = "0")
  public int saleSum;
  @Rules(fieldName = "图片数组ID", required = false)
  public int imgArrId;
  @Rules(fieldName = "所属的二级分类ID")
  public int childId;

  public Date createDate;
  public Date updateDate;

  /**
   * 点击次数
   */
  public int clickCount;

  /**
   * 缩略图URL
   */
  @Rules(fieldName = "缩略图", required = false)
  public String thumbImgUrl;

  @Id
  @Column(name = "id", nullable = false)
  public int getId() {
    return id;
  }

  public void setId(int id) {
    this.id = id;
  }

  @Basic
  @Column(name = "orderNum", nullable = false)
  public int getOrderNum() {
    return orderNum;
  }

  public void setOrderNum(int orderNum) {
    this.orderNum = orderNum;
  }

  @Basic
  @Column(name = "name", nullable = false, length = 50)
  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  @Basic
  @Column(name = "mark", nullable = false, length = 50)
  public String getMark() {
    return mark;
  }

  public void setMark(String mark) {
    this.mark = mark;
  }

  @Basic
  @Column(name = "salePrice", nullable = false, precision = 2)
  public BigDecimal getSalePrice() {
    return salePrice;
  }

  public void setSalePrice(BigDecimal salePrice) {
    this.salePrice = salePrice;
  }

  @Basic
  @Column(name = "shoppePrice", nullable = false, precision = 2)
  public BigDecimal getShoppePrice() {
    return shoppePrice;
  }

  public void setShoppePrice(BigDecimal shoppePrice) {
    this.shoppePrice = shoppePrice;
  }

  @Basic
  @Column(name = "num", nullable = false)
  public int getNum() {
    return num;
  }

  public void setNum(int num) {
    this.num = num;
  }

  @Basic
  @Column(name = "saleSum", nullable = false)
  public int getSaleSum() {
    return saleSum;
  }

  public void setSaleSum(int saleSum) {
    this.saleSum = saleSum;
  }

  @Basic
  @Column(name = "imgArrId", nullable = false)
  public int getImgArrId() {
    return imgArrId;
  }

  public void setImgArrId(int imgArrId) {
    this.imgArrId = imgArrId;
  }

  @Basic
  @Column(name = "childId", nullable = false)
  public int getChildId() {
    return childId;
  }

  public void setChildId(int childId) {
    this.childId = childId;
  }

  @Basic
  @Column(name = "createDate", nullable = false)
  public Date getCreateDate() {
    return createDate;
  }

  public void setCreateDate(Date createDate) {
    this.createDate = createDate;
  }

  @Basic
  @Column(name = "updateDate", nullable = false)
  public Date getUpdateDate() {
    return updateDate;
  }

  public void setUpdateDate(Date updateDate) {
    this.updateDate = updateDate;
  }

  @Basic
  @Column(name = "clickCount", nullable = false)
  public int getClickCount() {
    return clickCount;
  }

  public void setClickCount(int clickCount) {
    this.clickCount = clickCount;
  }

  @Basic
  @Column(name = "thumbImgUrl", nullable = false, length = 100)
  public String getThumbImgUrl() {
    return thumbImgUrl;
  }

  public void setThumbImgUrl(String thumbImgUrl) {
    this.thumbImgUrl = thumbImgUrl;
  }


  @Override
  public int hashCode() {
    int result = id;
    result = 31 * result + orderNum;
    result = 31 * result + (name != null ? name.hashCode() : 0);
    result = 31 * result + (mark != null ? mark.hashCode() : 0);
    result = 31 * result + (salePrice != null ? salePrice.hashCode() : 0);
    result = 31 * result + (shoppePrice != null ? shoppePrice.hashCode() : 0);
    result = 31 * result + num;
    result = 31 * result + saleSum;
    result = 31 * result + imgArrId;
    result = 31 * result + childId;
    result = 31 * result + (createDate != null ? createDate.hashCode() : 0);
    result = 31 * result + (updateDate != null ? updateDate.hashCode() : 0);
    result = 31 * result + clickCount;
    result = 31 * result + (thumbImgUrl != null ? thumbImgUrl.hashCode() : 0);
    return result;
  }

  @Override
  public boolean validate() {
    return defaultValidate();
  }
}
